/* eslint-disable */
import axios from 'axios'
// import {message} from 'antd'

export const BASE_URL = 'http://localhost:8080/api'
// create an axios instance
const service = axios.create({
    baseURL: BASE_URL, // api的base_url
    timeout: 10000*6*60*2, // request timeout
    // 是否允许携带cookie
    // withCredentials: true
})

// request interceptor
service.interceptors.request.use(config => {
    return config
}, error => {
    // Do something with request error
    console.log(error) // for debug
    Promise.reject(error)
})

// respone拦截器
service.interceptors.response.use(
    response => {

        const res = response.data
        // console.log('得到的请求响应======', res)
        if (res.code !== 200) {
            return response
        } else{
            console.log('!200')
            return response
        }
    },
    error => {
        console.log('err' + error) // for debug
        // message.error((error.message&&error.message.indexOf("timeout"))?"服务器连接超时": "服务器错误", 5)

        return Promise.reject(error)
    }
)

export default service
